Component({
  options: {
    multipleSlots: true
  },
  properties: {
    tabs: { //选项卡导航栏
      type: Array,
      value: []
    },
    align: { //对齐方式
      type: String,
      value: 'center'
    },
    bgColor: { //导航栏背景颜色
      type: String,
      value: '#fff'
    },
    color: { //导航栏文本颜色
      type: String,
      value: '#666'
    },
    currentColor: { //当前激活的颜色
      type: String,
      value: '#3565ee'
    },
    gap: { //间距
      type: [String, Number],
      value: 8
    },
    current: { //当前激活的导航栏
      type: [String, Number],
      value: 0,
      observer: function (newVal) {
        let value = parseInt(newVal);
        if (isNaN(value)) return;
        this.setData({
          currentIndex: value
        })
      }
    },
    scrollInto: { //值应为某子元素id（id不能以数字开头）。设置哪个方向可滚动，则在哪个方向滚动到该元素
      type: String,
      value: '',
      observer: function (newVal) {
        if (!newVal) return;
        this.setData({
          scrollIntoView: newVal
        })
      }
    }
  },
  data: {
    currentIndex: 0,
    scrollIntoView:''
  },
  lifetimes: {
    attached: function () {
      
    }
  },
  methods: {
    tabClick(e) {
      let current = parseInt(e.currentTarget.dataset.index);
      this.setData({
        currentIndex: current
      })
      this.triggerEvent('change', current)
    }
  }
})